﻿Imports System.Windows.Forms
Imports ajayumi.develop.win32.WebResourcesCatcher.Service

Public Class WebResourceCatcherManager

    Private Shared m_Instance As WebResourceCatcherManager
    Public Shared ReadOnly Property Instance() As WebResourceCatcherManager
        Get
            Return m_Instance
        End Get
    End Property

    Private m_TpDgvResources As List(Of TpDgvResource)
    Public ReadOnly Property TpDgvResources() As List(Of TpDgvResource)
        Get
            Return m_TpDgvResources
        End Get
    End Property


    Shared Sub New()
        m_Instance = New WebResourceCatcherManager()
    End Sub

    Sub New()
        m_TpDgvResources = New List(Of TpDgvResource)()
    End Sub


    Public Shared Sub Add(frm As IMainFormBase, resTaskInfo As ResTaskInfo)
        Dim _TabPage As New TabPage(resTaskInfo.SiteUrl)
        Dim _TpDgvResource As New TpDgvResource() With {.Dock = DockStyle.Fill, _
                                                        .ResTaskInfo = resTaskInfo}
        Instance.TpDgvResources.Add(_TpDgvResource)
        _TabPage.Controls.Add(_TpDgvResource)
        _TpDgvResource.Start()
        frm.AddTabPage(_TabPage)
    End Sub

    Public Shared Sub Close()
        Instance.TpDgvResources.ForEach(Sub(dgv As TpDgvResource)
                                            dgv.Close()
                                        End Sub)
    End Sub



End Class
